const { ccclass, property } = cc._decorator;
declare let i18n,DBManager,dbh;
import BaseView from "../../component/BaseView";
import DrawOne from "../DrawOne";
import Utils = require("../../utils/Utils");
import UIHelper = require("../../component/UIHelper");
import PopUIHelper = require("../../utils/PopUIHelper");
//清理腿毛 关卡15
@ccclass
export default class DeputyCleanLegView extends BaseView {
    @property(cc.Label)
    lblStep: cc.Label = null;
    @property(cc.Label)
    lblDes: cc.Label = null;
    @property(cc.Node)
    bgNode: cc.Node = null;
    @property(DrawOne)
    Draw: DrawOne = null;
    @property(cc.Node)
    tuiziNode: cc.Node = null;
    @property(cc.Node)
    legNode: cc.Node = null;
    @property(cc.Node)
    doneNode: cc.Node = null;

    //恭喜获得
    @property(cc.Node)
    endNode: cc.Node = null;

    _done = false;
    _shanShuo = false;
    _isStart = false;
    _isEnd = false;

    _isStartGua = false;
    onLoad() {
        Utils.audioManager.playBGM("huazhuang/deputyGame/deputyGameBg");
        this.bgNode.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.bgNode.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.bgNode.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
        //@ts-ignore
        this._isStart = this.node.openParam;
        this.lblStep.string = i18n.t("DEPUTY_GAME_STEP_TITLE15");
        this.lblDes.string = i18n.t("DEPUTY_GAME_STEP_DES15");
        Utils.audioManager.playSound("huazhuang/deputyGame/step_15_1");
    };
    onClose(){
        Utils.audioManager.playDefaultBGM();
    };
    onTouchStart(event){
        if(this._done)
            return;
        this.Draw._touchStart(event,cc.v2(0,0));
    };

    onTouchMove(event){
        if(this._done)
            return;
        this.Draw._touchMove(event);
        if(!this._isStartGua){
            this._isStartGua = true;
            Utils.audioManager.playSound("huazhuang/deputyGame/step_15_2");
        }
    };
    onTouchEnd(event){
        if(this._done)
            return;
        this.Draw._touchEnd(() => {
            this.doneNode.active = true;
            this.Draw.node.active = false;
            this.legNode.active = false;
            this.tuiziNode.active = false;
            //@ts-ignore
            this.scheduleOnce(()=>{
                this.endNode.active = true;
                Utils.audioManager.playSound("huazhuang/deputyGame/pass");
            },1);
        });
    };

    onClickEnd(isSkip){
        let next = this.params.next && this.params.next.shift();
        if (next) {
            UIHelper.openUI(next, {
                next: this.params.next
            })
            this.node.destroy();
        }
    };

    onClickSkip(){
        this.onClickEnd(true);
    };
    
    //提示
    onClickTips(){
        PopUIHelper.helper.showNewConfirmMsg(i18n.t("DEPUTY_GAME_TIPS15"));
    };

    
    
}
